import request from '@/utils/request'
import { IPage } from '@/model/interface/request'
import { IRole } from '@/model/interface/role'

const roleUrl = '/sys/role'

// 获取所有角色列表
export const getRoleAPI = (params: IPage) =>
  request({
    url: roleUrl,
    params
  })

// 根据ID获取角色详情
export const getRoleInfoAPI = (id: string) =>
  request({
    url: `${roleUrl}/${id}`
  })

// 根据ID删除角色
export const delRoleAPI = (id: string) =>
  request({
    url: `${roleUrl}/${id}`,
    method: 'DELETE'
  })

// 根据ID更新角色
export const editRoleAPI = (id: string, data: IRole) =>
  request({
    url: `${roleUrl}/${id}`,
    method: 'PUT',
    data
  })

// 添加角色
export const addRoleAPI = (data: IRole) =>
  request({
    url: roleUrl,
    method: 'post',
    data
  })

// 给角色分配权限
export const assignRoleAPI = (data: any) =>
  request({
    method: 'put',
    url: roleUrl + '/assignPrem',
    data
  })

// 获取公司信息
export const getCompanyInfoAPI = (id: number) =>
  request({
    url: `/company/${id}`
  })
